<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\Filters;

class Deal extends Model
{
     use Filters;
     protected $table = 'deals';

     protected $guarded = [];

     protected $casts = [
        'price' => 'float',
    ];

     public function user()
     {
          return $this->hasOne(User::class,'id','user_id');
     }

     public function transform_deal()
     {
          return [
               'deal_id' => $this->id,
               'total_price' => $this->total_price,
               'unit_price' => $this->price,
               'rest_amount' => $this->rest_amount,
               'total_amount' => $this->total_amount,
               'status' => $this->status,
               'create_at' => $this->created_at->toDateTimeString(),
          ];
     }


}
